{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Answers to Assignment 6 - Pandas Fundamentals\n",
    "\n",
    "Complete the tasks below. Please turn in a single Jupyter notebook named `6_first_last.ipynb` (substitute your first and last name). Please run Kernel > Restart & Run All on your notebook before turning in.\n",
    "\n",
    "#### The Earth Microbiome Project\n",
    "\n",
    "For this assignment, we will use Pandas to examine metadata from the [Earth Microbiome Project](http://earthmicrobiome.org/).\n",
    "\n",
    "First, download the metadata file for a 2,000-sample subset of the >27,000 samples in the Release 1 16S rRNA dataset.\n",
    "\n",
    "```\n",
    "curl -O \"ftp://ftp.microbio.me/emp/release1/mapping_files/emp_qiime_mapping_subset_2k.tsv\"\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import the required pacakges\n",
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# set the maximum number of rows displayed\n",
    "pd.set_option(\"display.max_rows\", 10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Answer to A. Reading and summarizing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A1. Import the tab-separated values file `emp_qiime_mapping_subset_2k.tsv` as a DataFrame called `df` with default data types, with the first row as column labels (columns) and the first column as row labels (indexes)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv('../../data/emp_qiime_mapping_subset_2k.tsv', sep='\\t', index_col=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A2. The indexes should be the sample IDs. How many samples are in this DataFrame? How many metadata columns?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2000, 75)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A3. What are the minimum and maximum pH values in the dataset?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3.45, 12.3)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.ph.min(), df.ph.max()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A4. What are the average and standard deviation temperature values in the dataset?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>study_id</th>\n",
       "      <th>read_length_bp</th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "      <th>sample_taxid</th>\n",
       "      <th>...</th>\n",
       "      <th>adiv_shannon</th>\n",
       "      <th>adiv_faith_pd</th>\n",
       "      <th>temperature_deg_c</th>\n",
       "      <th>ph</th>\n",
       "      <th>salinity_psu</th>\n",
       "      <th>oxygen_mg_per_l</th>\n",
       "      <th>phosphate_umol_per_l</th>\n",
       "      <th>ammonium_umol_per_l</th>\n",
       "      <th>nitrate_umol_per_l</th>\n",
       "      <th>sulfate_umol_per_l</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2.000000e+03</td>\n",
       "      <td>...</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>411.000000</td>\n",
       "      <td>284.000000</td>\n",
       "      <td>121.000000</td>\n",
       "      <td>26.000000</td>\n",
       "      <td>144.000000</td>\n",
       "      <td>81.000000</td>\n",
       "      <td>116.000000</td>\n",
       "      <td>17.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>1423.491000</td>\n",
       "      <td>125.751000</td>\n",
       "      <td>118683.372000</td>\n",
       "      <td>91485.516000</td>\n",
       "      <td>94659.511500</td>\n",
       "      <td>115786.274500</td>\n",
       "      <td>64789.053500</td>\n",
       "      <td>58213.264000</td>\n",
       "      <td>18119.118000</td>\n",
       "      <td>6.451546e+05</td>\n",
       "      <td>...</td>\n",
       "      <td>5.336688</td>\n",
       "      <td>45.323499</td>\n",
       "      <td>18.491088</td>\n",
       "      <td>8.123576</td>\n",
       "      <td>24.959681</td>\n",
       "      <td>10.935769</td>\n",
       "      <td>14.278391</td>\n",
       "      <td>236.644605</td>\n",
       "      <td>71.650086</td>\n",
       "      <td>2.517647</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>540.208383</td>\n",
       "      <td>24.318937</td>\n",
       "      <td>100946.740563</td>\n",
       "      <td>85329.714404</td>\n",
       "      <td>87431.980992</td>\n",
       "      <td>99960.933222</td>\n",
       "      <td>58928.224713</td>\n",
       "      <td>55653.344075</td>\n",
       "      <td>30223.641917</td>\n",
       "      <td>2.715913e+05</td>\n",
       "      <td>...</td>\n",
       "      <td>2.540171</td>\n",
       "      <td>42.088118</td>\n",
       "      <td>16.672381</td>\n",
       "      <td>1.684302</td>\n",
       "      <td>12.954485</td>\n",
       "      <td>1.676604</td>\n",
       "      <td>36.338796</td>\n",
       "      <td>654.115023</td>\n",
       "      <td>243.730156</td>\n",
       "      <td>0.811815</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>550.000000</td>\n",
       "      <td>90.000000</td>\n",
       "      <td>10470.000000</td>\n",
       "      <td>10030.000000</td>\n",
       "      <td>10253.000000</td>\n",
       "      <td>10457.000000</td>\n",
       "      <td>5275.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>5.549700e+04</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.000000</td>\n",
       "      <td>1.432725</td>\n",
       "      <td>-15.000000</td>\n",
       "      <td>3.450000</td>\n",
       "      <td>0.043900</td>\n",
       "      <td>8.400000</td>\n",
       "      <td>0.002527</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>925.000000</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>53760.500000</td>\n",
       "      <td>36146.000000</td>\n",
       "      <td>37562.500000</td>\n",
       "      <td>49896.500000</td>\n",
       "      <td>28138.750000</td>\n",
       "      <td>22395.750000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>4.122310e+05</td>\n",
       "      <td>...</td>\n",
       "      <td>3.728895</td>\n",
       "      <td>14.737926</td>\n",
       "      <td>9.714750</td>\n",
       "      <td>7.300000</td>\n",
       "      <td>7.440000</td>\n",
       "      <td>9.300000</td>\n",
       "      <td>0.348971</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.332500</td>\n",
       "      <td>1.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1521.000000</td>\n",
       "      <td>138.000000</td>\n",
       "      <td>92211.500000</td>\n",
       "      <td>66816.000000</td>\n",
       "      <td>69017.000000</td>\n",
       "      <td>89555.500000</td>\n",
       "      <td>50559.500000</td>\n",
       "      <td>47044.500000</td>\n",
       "      <td>4042.000000</td>\n",
       "      <td>5.561820e+05</td>\n",
       "      <td>...</td>\n",
       "      <td>5.544158</td>\n",
       "      <td>30.635928</td>\n",
       "      <td>15.240000</td>\n",
       "      <td>8.061450</td>\n",
       "      <td>31.400000</td>\n",
       "      <td>10.650000</td>\n",
       "      <td>0.955000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>2.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>1773.000000</td>\n",
       "      <td>150.000000</td>\n",
       "      <td>148746.750000</td>\n",
       "      <td>117519.250000</td>\n",
       "      <td>120490.500000</td>\n",
       "      <td>144549.750000</td>\n",
       "      <td>81776.750000</td>\n",
       "      <td>74205.000000</td>\n",
       "      <td>26975.000000</td>\n",
       "      <td>7.499060e+05</td>\n",
       "      <td>...</td>\n",
       "      <td>7.202397</td>\n",
       "      <td>61.773213</td>\n",
       "      <td>20.207798</td>\n",
       "      <td>9.000000</td>\n",
       "      <td>34.966800</td>\n",
       "      <td>12.137500</td>\n",
       "      <td>4.090000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>16.455000</td>\n",
       "      <td>3.300000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2382.000000</td>\n",
       "      <td>151.000000</td>\n",
       "      <td>819180.000000</td>\n",
       "      <td>713117.000000</td>\n",
       "      <td>717450.000000</td>\n",
       "      <td>814606.000000</td>\n",
       "      <td>589438.000000</td>\n",
       "      <td>573024.000000</td>\n",
       "      <td>294681.000000</td>\n",
       "      <td>1.649191e+06</td>\n",
       "      <td>...</td>\n",
       "      <td>10.738627</td>\n",
       "      <td>257.719293</td>\n",
       "      <td>91.000000</td>\n",
       "      <td>12.300000</td>\n",
       "      <td>37.065900</td>\n",
       "      <td>13.800000</td>\n",
       "      <td>205.000000</td>\n",
       "      <td>3450.000000</td>\n",
       "      <td>1653.000000</td>\n",
       "      <td>3.700000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 28 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          study_id  read_length_bp  sequences_split_libraries  \\\n",
       "count  2000.000000     2000.000000                2000.000000   \n",
       "mean   1423.491000      125.751000              118683.372000   \n",
       "std     540.208383       24.318937              100946.740563   \n",
       "min     550.000000       90.000000               10470.000000   \n",
       "25%     925.000000      100.000000               53760.500000   \n",
       "50%    1521.000000      138.000000               92211.500000   \n",
       "75%    1773.000000      150.000000              148746.750000   \n",
       "max    2382.000000      151.000000              819180.000000   \n",
       "\n",
       "       observations_closed_ref_greengenes  observations_closed_ref_silva  \\\n",
       "count                         2000.000000                    2000.000000   \n",
       "mean                         91485.516000                   94659.511500   \n",
       "std                          85329.714404                   87431.980992   \n",
       "min                          10030.000000                   10253.000000   \n",
       "25%                          36146.000000                   37562.500000   \n",
       "50%                          66816.000000                   69017.000000   \n",
       "75%                         117519.250000                  120490.500000   \n",
       "max                         713117.000000                  717450.000000   \n",
       "\n",
       "       observations_open_ref_greengenes  observations_deblur_90bp  \\\n",
       "count                       2000.000000               2000.000000   \n",
       "mean                      115786.274500              64789.053500   \n",
       "std                        99960.933222              58928.224713   \n",
       "min                        10457.000000               5275.000000   \n",
       "25%                        49896.500000              28138.750000   \n",
       "50%                        89555.500000              50559.500000   \n",
       "75%                       144549.750000              81776.750000   \n",
       "max                       814606.000000             589438.000000   \n",
       "\n",
       "       observations_deblur_100bp  observations_deblur_150bp  sample_taxid  \\\n",
       "count                2000.000000                2000.000000  2.000000e+03   \n",
       "mean                58213.264000               18119.118000  6.451546e+05   \n",
       "std                 55653.344075               30223.641917  2.715913e+05   \n",
       "min                     0.000000                   0.000000  5.549700e+04   \n",
       "25%                 22395.750000                   0.000000  4.122310e+05   \n",
       "50%                 47044.500000                4042.000000  5.561820e+05   \n",
       "75%                 74205.000000               26975.000000  7.499060e+05   \n",
       "max                573024.000000              294681.000000  1.649191e+06   \n",
       "\n",
       "              ...          adiv_shannon  adiv_faith_pd  temperature_deg_c  \\\n",
       "count         ...           2000.000000    2000.000000         411.000000   \n",
       "mean          ...              5.336688      45.323499          18.491088   \n",
       "std           ...              2.540171      42.088118          16.672381   \n",
       "min           ...             -0.000000       1.432725         -15.000000   \n",
       "25%           ...              3.728895      14.737926           9.714750   \n",
       "50%           ...              5.544158      30.635928          15.240000   \n",
       "75%           ...              7.202397      61.773213          20.207798   \n",
       "max           ...             10.738627     257.719293          91.000000   \n",
       "\n",
       "               ph  salinity_psu  oxygen_mg_per_l  phosphate_umol_per_l  \\\n",
       "count  284.000000    121.000000        26.000000            144.000000   \n",
       "mean     8.123576     24.959681        10.935769             14.278391   \n",
       "std      1.684302     12.954485         1.676604             36.338796   \n",
       "min      3.450000      0.043900         8.400000              0.002527   \n",
       "25%      7.300000      7.440000         9.300000              0.348971   \n",
       "50%      8.061450     31.400000        10.650000              0.955000   \n",
       "75%      9.000000     34.966800        12.137500              4.090000   \n",
       "max     12.300000     37.065900        13.800000            205.000000   \n",
       "\n",
       "       ammonium_umol_per_l  nitrate_umol_per_l  sulfate_umol_per_l  \n",
       "count            81.000000          116.000000           17.000000  \n",
       "mean            236.644605           71.650086            2.517647  \n",
       "std             654.115023          243.730156            0.811815  \n",
       "min               0.000000            0.000000            1.000000  \n",
       "25%               0.200000            0.332500            1.800000  \n",
       "50%               2.000000            5.000000            2.800000  \n",
       "75%              15.000000           16.455000            3.300000  \n",
       "max            3450.000000         1653.000000            3.700000  \n",
       "\n",
       "[8 rows x 28 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Answers:**\n",
    "\n",
    "* There are 2000 samples and 75 metadata columns.\n",
    "* The min and max pH values are 3.45, 12.3.\n",
    "* The mean and std temperature values are 18.5, 16.7."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Answer to B. Indexing, slicing, and writing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "B1. Make a new Series called `temp` with the temperature column as its own Series object. Remove NaN values (`np.nan`) from this Series. How many values are left?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "temp = df.temperature_deg_c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "temp.dropna(inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "#SampleID\n",
       "678.OA.mesocosm.362                                       11.000000\n",
       "678.OA.mesocosm.376                                       10.800000\n",
       "678.OA.mesocosm.410                                       12.100000\n",
       "678.OA.mesocosm.417                                       11.000000\n",
       "678.OA.mesocosm.431                                       11.100000\n",
       "                                                            ...    \n",
       "2229.W2.T3.4.HP1.Thomas.CMB.Seaweed.lane5.NoIndex.L005    18.300000\n",
       "2229.W2.T33.PS5.Thomas.CMB.Seaweed.lane6.NoIndex.L006     20.236952\n",
       "2300.BB.4087.anus                                         35.055556\n",
       "2300.BB.4087.lavage20                                     35.055556\n",
       "2300.BB.08.lavage20                                       36.222222\n",
       "Name: temperature_deg_c, Length: 411, dtype: float64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "temp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "B2. Make a new DataFrame called `df_seqs` from columns `sequences_split_libraries` through `observations_deblur_150bp` (column positions 17-23) of the existing DataFrame. What is the mean value of `column observations_deblur_90bp`?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>#SampleID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>550.L1S116.s.1.sequence</th>\n",
       "      <td>33383</td>\n",
       "      <td>32153</td>\n",
       "      <td>32453</td>\n",
       "      <td>33337</td>\n",
       "      <td>22567</td>\n",
       "      <td>22160</td>\n",
       "      <td>1043</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S119.s.1.sequence</th>\n",
       "      <td>40944</td>\n",
       "      <td>39472</td>\n",
       "      <td>39929</td>\n",
       "      <td>40870</td>\n",
       "      <td>27871</td>\n",
       "      <td>27191</td>\n",
       "      <td>1272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S164.s.1.sequence</th>\n",
       "      <td>35636</td>\n",
       "      <td>34550</td>\n",
       "      <td>34666</td>\n",
       "      <td>35599</td>\n",
       "      <td>24134</td>\n",
       "      <td>23686</td>\n",
       "      <td>1161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S194.s.1.sequence</th>\n",
       "      <td>46992</td>\n",
       "      <td>43925</td>\n",
       "      <td>43852</td>\n",
       "      <td>46875</td>\n",
       "      <td>30041</td>\n",
       "      <td>29264</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S20.s.1.sequence</th>\n",
       "      <td>30131</td>\n",
       "      <td>29179</td>\n",
       "      <td>29553</td>\n",
       "      <td>30094</td>\n",
       "      <td>21132</td>\n",
       "      <td>20643</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         sequences_split_libraries  \\\n",
       "#SampleID                                            \n",
       "550.L1S116.s.1.sequence                      33383   \n",
       "550.L1S119.s.1.sequence                      40944   \n",
       "550.L1S164.s.1.sequence                      35636   \n",
       "550.L1S194.s.1.sequence                      46992   \n",
       "550.L1S20.s.1.sequence                       30131   \n",
       "\n",
       "                         observations_closed_ref_greengenes  \\\n",
       "#SampleID                                                     \n",
       "550.L1S116.s.1.sequence                               32153   \n",
       "550.L1S119.s.1.sequence                               39472   \n",
       "550.L1S164.s.1.sequence                               34550   \n",
       "550.L1S194.s.1.sequence                               43925   \n",
       "550.L1S20.s.1.sequence                                29179   \n",
       "\n",
       "                         observations_closed_ref_silva  \\\n",
       "#SampleID                                                \n",
       "550.L1S116.s.1.sequence                          32453   \n",
       "550.L1S119.s.1.sequence                          39929   \n",
       "550.L1S164.s.1.sequence                          34666   \n",
       "550.L1S194.s.1.sequence                          43852   \n",
       "550.L1S20.s.1.sequence                           29553   \n",
       "\n",
       "                         observations_open_ref_greengenes  \\\n",
       "#SampleID                                                   \n",
       "550.L1S116.s.1.sequence                             33337   \n",
       "550.L1S119.s.1.sequence                             40870   \n",
       "550.L1S164.s.1.sequence                             35599   \n",
       "550.L1S194.s.1.sequence                             46875   \n",
       "550.L1S20.s.1.sequence                              30094   \n",
       "\n",
       "                         observations_deblur_90bp  observations_deblur_100bp  \\\n",
       "#SampleID                                                                      \n",
       "550.L1S116.s.1.sequence                     22567                      22160   \n",
       "550.L1S119.s.1.sequence                     27871                      27191   \n",
       "550.L1S164.s.1.sequence                     24134                      23686   \n",
       "550.L1S194.s.1.sequence                     30041                      29264   \n",
       "550.L1S20.s.1.sequence                      21132                      20643   \n",
       "\n",
       "                         observations_deblur_150bp  \n",
       "#SampleID                                           \n",
       "550.L1S116.s.1.sequence                       1043  \n",
       "550.L1S119.s.1.sequence                       1272  \n",
       "550.L1S164.s.1.sequence                       1161  \n",
       "550.L1S194.s.1.sequence                       1974  \n",
       "550.L1S20.s.1.sequence                         603  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_seqs = df.iloc[:, 17:24]\n",
    "df_seqs.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can get the means from `describe()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "      <td>2000.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>118683.372000</td>\n",
       "      <td>91485.516000</td>\n",
       "      <td>94659.511500</td>\n",
       "      <td>115786.274500</td>\n",
       "      <td>64789.053500</td>\n",
       "      <td>58213.264000</td>\n",
       "      <td>18119.118000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>100946.740563</td>\n",
       "      <td>85329.714404</td>\n",
       "      <td>87431.980992</td>\n",
       "      <td>99960.933222</td>\n",
       "      <td>58928.224713</td>\n",
       "      <td>55653.344075</td>\n",
       "      <td>30223.641917</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>10470.000000</td>\n",
       "      <td>10030.000000</td>\n",
       "      <td>10253.000000</td>\n",
       "      <td>10457.000000</td>\n",
       "      <td>5275.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>53760.500000</td>\n",
       "      <td>36146.000000</td>\n",
       "      <td>37562.500000</td>\n",
       "      <td>49896.500000</td>\n",
       "      <td>28138.750000</td>\n",
       "      <td>22395.750000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>92211.500000</td>\n",
       "      <td>66816.000000</td>\n",
       "      <td>69017.000000</td>\n",
       "      <td>89555.500000</td>\n",
       "      <td>50559.500000</td>\n",
       "      <td>47044.500000</td>\n",
       "      <td>4042.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>148746.750000</td>\n",
       "      <td>117519.250000</td>\n",
       "      <td>120490.500000</td>\n",
       "      <td>144549.750000</td>\n",
       "      <td>81776.750000</td>\n",
       "      <td>74205.000000</td>\n",
       "      <td>26975.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>819180.000000</td>\n",
       "      <td>713117.000000</td>\n",
       "      <td>717450.000000</td>\n",
       "      <td>814606.000000</td>\n",
       "      <td>589438.000000</td>\n",
       "      <td>573024.000000</td>\n",
       "      <td>294681.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       sequences_split_libraries  observations_closed_ref_greengenes  \\\n",
       "count                2000.000000                         2000.000000   \n",
       "mean               118683.372000                        91485.516000   \n",
       "std                100946.740563                        85329.714404   \n",
       "min                 10470.000000                        10030.000000   \n",
       "25%                 53760.500000                        36146.000000   \n",
       "50%                 92211.500000                        66816.000000   \n",
       "75%                148746.750000                       117519.250000   \n",
       "max                819180.000000                       713117.000000   \n",
       "\n",
       "       observations_closed_ref_silva  observations_open_ref_greengenes  \\\n",
       "count                    2000.000000                       2000.000000   \n",
       "mean                    94659.511500                     115786.274500   \n",
       "std                     87431.980992                      99960.933222   \n",
       "min                     10253.000000                      10457.000000   \n",
       "25%                     37562.500000                      49896.500000   \n",
       "50%                     69017.000000                      89555.500000   \n",
       "75%                    120490.500000                     144549.750000   \n",
       "max                    717450.000000                     814606.000000   \n",
       "\n",
       "       observations_deblur_90bp  observations_deblur_100bp  \\\n",
       "count               2000.000000                2000.000000   \n",
       "mean               64789.053500               58213.264000   \n",
       "std                58928.224713               55653.344075   \n",
       "min                 5275.000000                   0.000000   \n",
       "25%                28138.750000               22395.750000   \n",
       "50%                50559.500000               47044.500000   \n",
       "75%                81776.750000               74205.000000   \n",
       "max               589438.000000              573024.000000   \n",
       "\n",
       "       observations_deblur_150bp  \n",
       "count                2000.000000  \n",
       "mean                18119.118000  \n",
       "std                 30223.641917  \n",
       "min                     0.000000  \n",
       "25%                     0.000000  \n",
       "50%                  4042.000000  \n",
       "75%                 26975.000000  \n",
       "max                294681.000000  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_seqs.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "...or we can get the mean on a single column (Series) using `mean()`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "64789.0535"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_seqs.observations_deblur_90bp.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "B3. Save `df_seqs` as a csv file."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_seqs.to_csv('emp_qiime_mapping_subset_2k_seqs.csv')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Answers:**\n",
    "\n",
    "* There are 411 non-NaN temperature values.\n",
    "* The mean value of observations_deblur_90bp is 64789.0535."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Answers to C. Merging, joining, and concatenating"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "C1. Store the first 5 rows of `df_seqs` as a new dataframe called `df_seqs_head`. Store the last 5 rows of `df_seqs` as a new dataframe called `df_seqs_tail`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "df_seqs_head = df_seqs.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_seqs_tail = df_seqs.tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "C2. Concatenate `df_seqs_head` and `df_seqs_tail` using the `concat()` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>#SampleID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>550.L1S116.s.1.sequence</th>\n",
       "      <td>33383</td>\n",
       "      <td>32153</td>\n",
       "      <td>32453</td>\n",
       "      <td>33337</td>\n",
       "      <td>22567</td>\n",
       "      <td>22160</td>\n",
       "      <td>1043</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S119.s.1.sequence</th>\n",
       "      <td>40944</td>\n",
       "      <td>39472</td>\n",
       "      <td>39929</td>\n",
       "      <td>40870</td>\n",
       "      <td>27871</td>\n",
       "      <td>27191</td>\n",
       "      <td>1272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S164.s.1.sequence</th>\n",
       "      <td>35636</td>\n",
       "      <td>34550</td>\n",
       "      <td>34666</td>\n",
       "      <td>35599</td>\n",
       "      <td>24134</td>\n",
       "      <td>23686</td>\n",
       "      <td>1161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S194.s.1.sequence</th>\n",
       "      <td>46992</td>\n",
       "      <td>43925</td>\n",
       "      <td>43852</td>\n",
       "      <td>46875</td>\n",
       "      <td>30041</td>\n",
       "      <td>29264</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S20.s.1.sequence</th>\n",
       "      <td>30131</td>\n",
       "      <td>29179</td>\n",
       "      <td>29553</td>\n",
       "      <td>30094</td>\n",
       "      <td>21132</td>\n",
       "      <td>20643</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L008.sequences</th>\n",
       "      <td>125047</td>\n",
       "      <td>124344</td>\n",
       "      <td>123968</td>\n",
       "      <td>124983</td>\n",
       "      <td>90850</td>\n",
       "      <td>88922</td>\n",
       "      <td>78308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex.L008.sequences</th>\n",
       "      <td>138753</td>\n",
       "      <td>138268</td>\n",
       "      <td>138165</td>\n",
       "      <td>138702</td>\n",
       "      <td>115902</td>\n",
       "      <td>113556</td>\n",
       "      <td>96934</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex.L007.sequences</th>\n",
       "      <td>345657</td>\n",
       "      <td>243403</td>\n",
       "      <td>272832</td>\n",
       "      <td>342881</td>\n",
       "      <td>204706</td>\n",
       "      <td>210622</td>\n",
       "      <td>174759</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex.L007.sequences</th>\n",
       "      <td>89747</td>\n",
       "      <td>62332</td>\n",
       "      <td>70308</td>\n",
       "      <td>88986</td>\n",
       "      <td>53892</td>\n",
       "      <td>54960</td>\n",
       "      <td>45749</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex.L001.sequences</th>\n",
       "      <td>92336</td>\n",
       "      <td>66419</td>\n",
       "      <td>71897</td>\n",
       "      <td>90693</td>\n",
       "      <td>50070</td>\n",
       "      <td>51053</td>\n",
       "      <td>42505</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    sequences_split_libraries  \\\n",
       "#SampleID                                                                       \n",
       "550.L1S116.s.1.sequence                                                 33383   \n",
       "550.L1S119.s.1.sequence                                                 40944   \n",
       "550.L1S164.s.1.sequence                                                 35636   \n",
       "550.L1S194.s.1.sequence                                                 46992   \n",
       "550.L1S20.s.1.sequence                                                  30131   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                     125047   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                     138753   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                     345657   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                      89747   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                      92336   \n",
       "\n",
       "                                                    observations_closed_ref_greengenes  \\\n",
       "#SampleID                                                                                \n",
       "550.L1S116.s.1.sequence                                                          32153   \n",
       "550.L1S119.s.1.sequence                                                          39472   \n",
       "550.L1S164.s.1.sequence                                                          34550   \n",
       "550.L1S194.s.1.sequence                                                          43925   \n",
       "550.L1S20.s.1.sequence                                                           29179   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                              124344   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                              138268   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                              243403   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                               62332   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                               66419   \n",
       "\n",
       "                                                    observations_closed_ref_silva  \\\n",
       "#SampleID                                                                           \n",
       "550.L1S116.s.1.sequence                                                     32453   \n",
       "550.L1S119.s.1.sequence                                                     39929   \n",
       "550.L1S164.s.1.sequence                                                     34666   \n",
       "550.L1S194.s.1.sequence                                                     43852   \n",
       "550.L1S20.s.1.sequence                                                      29553   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                         123968   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                         138165   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                         272832   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                          70308   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                          71897   \n",
       "\n",
       "                                                    observations_open_ref_greengenes  \\\n",
       "#SampleID                                                                              \n",
       "550.L1S116.s.1.sequence                                                        33337   \n",
       "550.L1S119.s.1.sequence                                                        40870   \n",
       "550.L1S164.s.1.sequence                                                        35599   \n",
       "550.L1S194.s.1.sequence                                                        46875   \n",
       "550.L1S20.s.1.sequence                                                         30094   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                            124983   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                            138702   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                            342881   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                             88986   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                             90693   \n",
       "\n",
       "                                                    observations_deblur_90bp  \\\n",
       "#SampleID                                                                      \n",
       "550.L1S116.s.1.sequence                                                22567   \n",
       "550.L1S119.s.1.sequence                                                27871   \n",
       "550.L1S164.s.1.sequence                                                24134   \n",
       "550.L1S194.s.1.sequence                                                30041   \n",
       "550.L1S20.s.1.sequence                                                 21132   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                     90850   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                    115902   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                    204706   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                     53892   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                     50070   \n",
       "\n",
       "                                                    observations_deblur_100bp  \\\n",
       "#SampleID                                                                       \n",
       "550.L1S116.s.1.sequence                                                 22160   \n",
       "550.L1S119.s.1.sequence                                                 27191   \n",
       "550.L1S164.s.1.sequence                                                 23686   \n",
       "550.L1S194.s.1.sequence                                                 29264   \n",
       "550.L1S20.s.1.sequence                                                  20643   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                      88922   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                     113556   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                     210622   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                      54960   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                      51053   \n",
       "\n",
       "                                                    observations_deblur_150bp  \n",
       "#SampleID                                                                      \n",
       "550.L1S116.s.1.sequence                                                  1043  \n",
       "550.L1S119.s.1.sequence                                                  1272  \n",
       "550.L1S164.s.1.sequence                                                  1161  \n",
       "550.L1S194.s.1.sequence                                                  1974  \n",
       "550.L1S20.s.1.sequence                                                    603  \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                      78308  \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                      96934  \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                     174759  \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                      45749  \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                      42505  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([df_seqs_head, df_seqs_tail])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "C3. Append `df_seqs_tail` to `df_seqs_head` using the `append()` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>#SampleID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>550.L1S116.s.1.sequence</th>\n",
       "      <td>33383</td>\n",
       "      <td>32153</td>\n",
       "      <td>32453</td>\n",
       "      <td>33337</td>\n",
       "      <td>22567</td>\n",
       "      <td>22160</td>\n",
       "      <td>1043</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S119.s.1.sequence</th>\n",
       "      <td>40944</td>\n",
       "      <td>39472</td>\n",
       "      <td>39929</td>\n",
       "      <td>40870</td>\n",
       "      <td>27871</td>\n",
       "      <td>27191</td>\n",
       "      <td>1272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S164.s.1.sequence</th>\n",
       "      <td>35636</td>\n",
       "      <td>34550</td>\n",
       "      <td>34666</td>\n",
       "      <td>35599</td>\n",
       "      <td>24134</td>\n",
       "      <td>23686</td>\n",
       "      <td>1161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S194.s.1.sequence</th>\n",
       "      <td>46992</td>\n",
       "      <td>43925</td>\n",
       "      <td>43852</td>\n",
       "      <td>46875</td>\n",
       "      <td>30041</td>\n",
       "      <td>29264</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S20.s.1.sequence</th>\n",
       "      <td>30131</td>\n",
       "      <td>29179</td>\n",
       "      <td>29553</td>\n",
       "      <td>30094</td>\n",
       "      <td>21132</td>\n",
       "      <td>20643</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L008.sequences</th>\n",
       "      <td>125047</td>\n",
       "      <td>124344</td>\n",
       "      <td>123968</td>\n",
       "      <td>124983</td>\n",
       "      <td>90850</td>\n",
       "      <td>88922</td>\n",
       "      <td>78308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex.L008.sequences</th>\n",
       "      <td>138753</td>\n",
       "      <td>138268</td>\n",
       "      <td>138165</td>\n",
       "      <td>138702</td>\n",
       "      <td>115902</td>\n",
       "      <td>113556</td>\n",
       "      <td>96934</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex.L007.sequences</th>\n",
       "      <td>345657</td>\n",
       "      <td>243403</td>\n",
       "      <td>272832</td>\n",
       "      <td>342881</td>\n",
       "      <td>204706</td>\n",
       "      <td>210622</td>\n",
       "      <td>174759</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex.L007.sequences</th>\n",
       "      <td>89747</td>\n",
       "      <td>62332</td>\n",
       "      <td>70308</td>\n",
       "      <td>88986</td>\n",
       "      <td>53892</td>\n",
       "      <td>54960</td>\n",
       "      <td>45749</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex.L001.sequences</th>\n",
       "      <td>92336</td>\n",
       "      <td>66419</td>\n",
       "      <td>71897</td>\n",
       "      <td>90693</td>\n",
       "      <td>50070</td>\n",
       "      <td>51053</td>\n",
       "      <td>42505</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    sequences_split_libraries  \\\n",
       "#SampleID                                                                       \n",
       "550.L1S116.s.1.sequence                                                 33383   \n",
       "550.L1S119.s.1.sequence                                                 40944   \n",
       "550.L1S164.s.1.sequence                                                 35636   \n",
       "550.L1S194.s.1.sequence                                                 46992   \n",
       "550.L1S20.s.1.sequence                                                  30131   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                     125047   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                     138753   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                     345657   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                      89747   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                      92336   \n",
       "\n",
       "                                                    observations_closed_ref_greengenes  \\\n",
       "#SampleID                                                                                \n",
       "550.L1S116.s.1.sequence                                                          32153   \n",
       "550.L1S119.s.1.sequence                                                          39472   \n",
       "550.L1S164.s.1.sequence                                                          34550   \n",
       "550.L1S194.s.1.sequence                                                          43925   \n",
       "550.L1S20.s.1.sequence                                                           29179   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                              124344   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                              138268   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                              243403   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                               62332   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                               66419   \n",
       "\n",
       "                                                    observations_closed_ref_silva  \\\n",
       "#SampleID                                                                           \n",
       "550.L1S116.s.1.sequence                                                     32453   \n",
       "550.L1S119.s.1.sequence                                                     39929   \n",
       "550.L1S164.s.1.sequence                                                     34666   \n",
       "550.L1S194.s.1.sequence                                                     43852   \n",
       "550.L1S20.s.1.sequence                                                      29553   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                         123968   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                         138165   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                         272832   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                          70308   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                          71897   \n",
       "\n",
       "                                                    observations_open_ref_greengenes  \\\n",
       "#SampleID                                                                              \n",
       "550.L1S116.s.1.sequence                                                        33337   \n",
       "550.L1S119.s.1.sequence                                                        40870   \n",
       "550.L1S164.s.1.sequence                                                        35599   \n",
       "550.L1S194.s.1.sequence                                                        46875   \n",
       "550.L1S20.s.1.sequence                                                         30094   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                            124983   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                            138702   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                            342881   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                             88986   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                             90693   \n",
       "\n",
       "                                                    observations_deblur_90bp  \\\n",
       "#SampleID                                                                      \n",
       "550.L1S116.s.1.sequence                                                22567   \n",
       "550.L1S119.s.1.sequence                                                27871   \n",
       "550.L1S164.s.1.sequence                                                24134   \n",
       "550.L1S194.s.1.sequence                                                30041   \n",
       "550.L1S20.s.1.sequence                                                 21132   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                     90850   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                    115902   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                    204706   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                     53892   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                     50070   \n",
       "\n",
       "                                                    observations_deblur_100bp  \\\n",
       "#SampleID                                                                       \n",
       "550.L1S116.s.1.sequence                                                 22160   \n",
       "550.L1S119.s.1.sequence                                                 27191   \n",
       "550.L1S164.s.1.sequence                                                 23686   \n",
       "550.L1S194.s.1.sequence                                                 29264   \n",
       "550.L1S20.s.1.sequence                                                  20643   \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                      88922   \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                     113556   \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                     210622   \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                      54960   \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                      51053   \n",
       "\n",
       "                                                    observations_deblur_150bp  \n",
       "#SampleID                                                                      \n",
       "550.L1S116.s.1.sequence                                                  1043  \n",
       "550.L1S119.s.1.sequence                                                  1272  \n",
       "550.L1S164.s.1.sequence                                                  1161  \n",
       "550.L1S194.s.1.sequence                                                  1974  \n",
       "550.L1S20.s.1.sequence                                                    603  \n",
       "2382.DPOO1.C1.HA.1.630.gp.9.12.lane8.NoIndex.L0...                      78308  \n",
       "2382.DPOO1.C1.HA.1.629.leav.9.12.lane8.NoIndex....                      96934  \n",
       "2382.DPOO1.C1.HA.1.628.root.9.12.lane7.NoIndex....                     174759  \n",
       "2382.DPOO1.C1.HA.1.428.root.4.12.lane7.NoIndex....                      45749  \n",
       "2382.DPOO1.C1.HA.1.228.root.9.11.lane1.NoIndex....                      42505  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_seqs_head.append(df_seqs_tail)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "C4. Make a new DataFrame called `df_phys` with the pH, temperature, and salinity columns (hint: you will need to know the exact column names; these are some of the last few columns). Make another new DataFrame called `df_empo` with the column `empo_3` (note: this will actually be a Series because it has only one column, but you can treat it like a DataFrame)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_phys = df[['ph', 'temperature_deg_c', 'salinity_psu']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_empo = df['empo_3']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "C5. Merge `df_phys` with `df_seqs` using the `merge()` function with the indexes of both DataFrames to make a new DataFrame called `df_merged`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ph</th>\n",
       "      <th>temperature_deg_c</th>\n",
       "      <th>salinity_psu</th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>#SampleID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>550.L1S116.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>33383</td>\n",
       "      <td>32153</td>\n",
       "      <td>32453</td>\n",
       "      <td>33337</td>\n",
       "      <td>22567</td>\n",
       "      <td>22160</td>\n",
       "      <td>1043</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S119.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>40944</td>\n",
       "      <td>39472</td>\n",
       "      <td>39929</td>\n",
       "      <td>40870</td>\n",
       "      <td>27871</td>\n",
       "      <td>27191</td>\n",
       "      <td>1272</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S164.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>35636</td>\n",
       "      <td>34550</td>\n",
       "      <td>34666</td>\n",
       "      <td>35599</td>\n",
       "      <td>24134</td>\n",
       "      <td>23686</td>\n",
       "      <td>1161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S194.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>46992</td>\n",
       "      <td>43925</td>\n",
       "      <td>43852</td>\n",
       "      <td>46875</td>\n",
       "      <td>30041</td>\n",
       "      <td>29264</td>\n",
       "      <td>1974</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S20.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>30131</td>\n",
       "      <td>29179</td>\n",
       "      <td>29553</td>\n",
       "      <td>30094</td>\n",
       "      <td>21132</td>\n",
       "      <td>20643</td>\n",
       "      <td>603</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         ph  temperature_deg_c  salinity_psu  \\\n",
       "#SampleID                                                      \n",
       "550.L1S116.s.1.sequence NaN                NaN           NaN   \n",
       "550.L1S119.s.1.sequence NaN                NaN           NaN   \n",
       "550.L1S164.s.1.sequence NaN                NaN           NaN   \n",
       "550.L1S194.s.1.sequence NaN                NaN           NaN   \n",
       "550.L1S20.s.1.sequence  NaN                NaN           NaN   \n",
       "\n",
       "                         sequences_split_libraries  \\\n",
       "#SampleID                                            \n",
       "550.L1S116.s.1.sequence                      33383   \n",
       "550.L1S119.s.1.sequence                      40944   \n",
       "550.L1S164.s.1.sequence                      35636   \n",
       "550.L1S194.s.1.sequence                      46992   \n",
       "550.L1S20.s.1.sequence                       30131   \n",
       "\n",
       "                         observations_closed_ref_greengenes  \\\n",
       "#SampleID                                                     \n",
       "550.L1S116.s.1.sequence                               32153   \n",
       "550.L1S119.s.1.sequence                               39472   \n",
       "550.L1S164.s.1.sequence                               34550   \n",
       "550.L1S194.s.1.sequence                               43925   \n",
       "550.L1S20.s.1.sequence                                29179   \n",
       "\n",
       "                         observations_closed_ref_silva  \\\n",
       "#SampleID                                                \n",
       "550.L1S116.s.1.sequence                          32453   \n",
       "550.L1S119.s.1.sequence                          39929   \n",
       "550.L1S164.s.1.sequence                          34666   \n",
       "550.L1S194.s.1.sequence                          43852   \n",
       "550.L1S20.s.1.sequence                           29553   \n",
       "\n",
       "                         observations_open_ref_greengenes  \\\n",
       "#SampleID                                                   \n",
       "550.L1S116.s.1.sequence                             33337   \n",
       "550.L1S119.s.1.sequence                             40870   \n",
       "550.L1S164.s.1.sequence                             35599   \n",
       "550.L1S194.s.1.sequence                             46875   \n",
       "550.L1S20.s.1.sequence                              30094   \n",
       "\n",
       "                         observations_deblur_90bp  observations_deblur_100bp  \\\n",
       "#SampleID                                                                      \n",
       "550.L1S116.s.1.sequence                     22567                      22160   \n",
       "550.L1S119.s.1.sequence                     27871                      27191   \n",
       "550.L1S164.s.1.sequence                     24134                      23686   \n",
       "550.L1S194.s.1.sequence                     30041                      29264   \n",
       "550.L1S20.s.1.sequence                      21132                      20643   \n",
       "\n",
       "                         observations_deblur_150bp  \n",
       "#SampleID                                           \n",
       "550.L1S116.s.1.sequence                       1043  \n",
       "550.L1S119.s.1.sequence                       1272  \n",
       "550.L1S164.s.1.sequence                       1161  \n",
       "550.L1S194.s.1.sequence                       1974  \n",
       "550.L1S20.s.1.sequence                         603  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merged = pd.merge(df_phys, df_seqs, left_index=True, right_index=True)\n",
    "df_merged.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "C6. Join `df_merged` with `df_empo` using the `join()` function and store the result as `df_merged`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ph</th>\n",
       "      <th>temperature_deg_c</th>\n",
       "      <th>salinity_psu</th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "      <th>empo_3</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>#SampleID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>550.L1S116.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>33383</td>\n",
       "      <td>32153</td>\n",
       "      <td>32453</td>\n",
       "      <td>33337</td>\n",
       "      <td>22567</td>\n",
       "      <td>22160</td>\n",
       "      <td>1043</td>\n",
       "      <td>Animal distal gut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S119.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>40944</td>\n",
       "      <td>39472</td>\n",
       "      <td>39929</td>\n",
       "      <td>40870</td>\n",
       "      <td>27871</td>\n",
       "      <td>27191</td>\n",
       "      <td>1272</td>\n",
       "      <td>Animal distal gut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S164.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>35636</td>\n",
       "      <td>34550</td>\n",
       "      <td>34666</td>\n",
       "      <td>35599</td>\n",
       "      <td>24134</td>\n",
       "      <td>23686</td>\n",
       "      <td>1161</td>\n",
       "      <td>Animal distal gut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S194.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>46992</td>\n",
       "      <td>43925</td>\n",
       "      <td>43852</td>\n",
       "      <td>46875</td>\n",
       "      <td>30041</td>\n",
       "      <td>29264</td>\n",
       "      <td>1974</td>\n",
       "      <td>Animal distal gut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550.L1S20.s.1.sequence</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>30131</td>\n",
       "      <td>29179</td>\n",
       "      <td>29553</td>\n",
       "      <td>30094</td>\n",
       "      <td>21132</td>\n",
       "      <td>20643</td>\n",
       "      <td>603</td>\n",
       "      <td>Animal distal gut</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         ph  temperature_deg_c  salinity_psu  \\\n",
       "#SampleID                                                      \n",
       "550.L1S116.s.1.sequence NaN                NaN           NaN   \n",
       "550.L1S119.s.1.sequence NaN                NaN           NaN   \n",
       "550.L1S164.s.1.sequence NaN                NaN           NaN   \n",
       "550.L1S194.s.1.sequence NaN                NaN           NaN   \n",
       "550.L1S20.s.1.sequence  NaN                NaN           NaN   \n",
       "\n",
       "                         sequences_split_libraries  \\\n",
       "#SampleID                                            \n",
       "550.L1S116.s.1.sequence                      33383   \n",
       "550.L1S119.s.1.sequence                      40944   \n",
       "550.L1S164.s.1.sequence                      35636   \n",
       "550.L1S194.s.1.sequence                      46992   \n",
       "550.L1S20.s.1.sequence                       30131   \n",
       "\n",
       "                         observations_closed_ref_greengenes  \\\n",
       "#SampleID                                                     \n",
       "550.L1S116.s.1.sequence                               32153   \n",
       "550.L1S119.s.1.sequence                               39472   \n",
       "550.L1S164.s.1.sequence                               34550   \n",
       "550.L1S194.s.1.sequence                               43925   \n",
       "550.L1S20.s.1.sequence                                29179   \n",
       "\n",
       "                         observations_closed_ref_silva  \\\n",
       "#SampleID                                                \n",
       "550.L1S116.s.1.sequence                          32453   \n",
       "550.L1S119.s.1.sequence                          39929   \n",
       "550.L1S164.s.1.sequence                          34666   \n",
       "550.L1S194.s.1.sequence                          43852   \n",
       "550.L1S20.s.1.sequence                           29553   \n",
       "\n",
       "                         observations_open_ref_greengenes  \\\n",
       "#SampleID                                                   \n",
       "550.L1S116.s.1.sequence                             33337   \n",
       "550.L1S119.s.1.sequence                             40870   \n",
       "550.L1S164.s.1.sequence                             35599   \n",
       "550.L1S194.s.1.sequence                             46875   \n",
       "550.L1S20.s.1.sequence                              30094   \n",
       "\n",
       "                         observations_deblur_90bp  observations_deblur_100bp  \\\n",
       "#SampleID                                                                      \n",
       "550.L1S116.s.1.sequence                     22567                      22160   \n",
       "550.L1S119.s.1.sequence                     27871                      27191   \n",
       "550.L1S164.s.1.sequence                     24134                      23686   \n",
       "550.L1S194.s.1.sequence                     30041                      29264   \n",
       "550.L1S20.s.1.sequence                      21132                      20643   \n",
       "\n",
       "                         observations_deblur_150bp             empo_3  \n",
       "#SampleID                                                              \n",
       "550.L1S116.s.1.sequence                       1043  Animal distal gut  \n",
       "550.L1S119.s.1.sequence                       1272  Animal distal gut  \n",
       "550.L1S164.s.1.sequence                       1161  Animal distal gut  \n",
       "550.L1S194.s.1.sequence                       1974  Animal distal gut  \n",
       "550.L1S20.s.1.sequence                         603  Animal distal gut  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merged = df_merged.join(df_empo)\n",
    "df_merged.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Answer to D. Applying functions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "D1. Use a list comprehension to add a new column to `df_merged` called `temperature_deg_f` which takes the values in `temperature_deg_c` and converts them to degrees Fahrenheit."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_merged['temperature_deg_f'] = [c * 1.8 + 32 for c in df_merged.temperature_deg_c]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "D2. Create a function that changes a single numerical value from Celsius to Fahrenheit. Apply this function to the values in `temperature_deg_c` using `apply()` to create a new column called `temperature_deg_f_2`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "def celsius_to_fahrenheit(c):\n",
    "    f = c * 1.8 + 32\n",
    "    return(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_merged['temperature_deg_f_2'] = df_merged['temperature_deg_c'].apply(celsius_to_fahrenheit)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To see the results, we can select the rows that have non-NA temperature values (not all samples have temperature data) and the columns containing the temperature data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>temperature_deg_c</th>\n",
       "      <th>temperature_deg_f</th>\n",
       "      <th>temperature_deg_f_2</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>#SampleID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>678.OA.mesocosm.362</th>\n",
       "      <td>11.000000</td>\n",
       "      <td>51.800000</td>\n",
       "      <td>51.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>678.OA.mesocosm.376</th>\n",
       "      <td>10.800000</td>\n",
       "      <td>51.440000</td>\n",
       "      <td>51.440000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>678.OA.mesocosm.410</th>\n",
       "      <td>12.100000</td>\n",
       "      <td>53.780000</td>\n",
       "      <td>53.780000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>678.OA.mesocosm.417</th>\n",
       "      <td>11.000000</td>\n",
       "      <td>51.800000</td>\n",
       "      <td>51.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>678.OA.mesocosm.431</th>\n",
       "      <td>11.100000</td>\n",
       "      <td>51.980000</td>\n",
       "      <td>51.980000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2229.W2.T3.4.HP1.Thomas.CMB.Seaweed.lane5.NoIndex.L005</th>\n",
       "      <td>18.300000</td>\n",
       "      <td>64.940000</td>\n",
       "      <td>64.940000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2229.W2.T33.PS5.Thomas.CMB.Seaweed.lane6.NoIndex.L006</th>\n",
       "      <td>20.236952</td>\n",
       "      <td>68.426513</td>\n",
       "      <td>68.426513</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2300.BB.4087.anus</th>\n",
       "      <td>35.055556</td>\n",
       "      <td>95.100000</td>\n",
       "      <td>95.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2300.BB.4087.lavage20</th>\n",
       "      <td>35.055556</td>\n",
       "      <td>95.100000</td>\n",
       "      <td>95.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2300.BB.08.lavage20</th>\n",
       "      <td>36.222222</td>\n",
       "      <td>97.200000</td>\n",
       "      <td>97.200000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>411 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    temperature_deg_c  \\\n",
       "#SampleID                                                               \n",
       "678.OA.mesocosm.362                                         11.000000   \n",
       "678.OA.mesocosm.376                                         10.800000   \n",
       "678.OA.mesocosm.410                                         12.100000   \n",
       "678.OA.mesocosm.417                                         11.000000   \n",
       "678.OA.mesocosm.431                                         11.100000   \n",
       "...                                                               ...   \n",
       "2229.W2.T3.4.HP1.Thomas.CMB.Seaweed.lane5.NoInd...          18.300000   \n",
       "2229.W2.T33.PS5.Thomas.CMB.Seaweed.lane6.NoInde...          20.236952   \n",
       "2300.BB.4087.anus                                           35.055556   \n",
       "2300.BB.4087.lavage20                                       35.055556   \n",
       "2300.BB.08.lavage20                                         36.222222   \n",
       "\n",
       "                                                    temperature_deg_f  \\\n",
       "#SampleID                                                               \n",
       "678.OA.mesocosm.362                                         51.800000   \n",
       "678.OA.mesocosm.376                                         51.440000   \n",
       "678.OA.mesocosm.410                                         53.780000   \n",
       "678.OA.mesocosm.417                                         51.800000   \n",
       "678.OA.mesocosm.431                                         51.980000   \n",
       "...                                                               ...   \n",
       "2229.W2.T3.4.HP1.Thomas.CMB.Seaweed.lane5.NoInd...          64.940000   \n",
       "2229.W2.T33.PS5.Thomas.CMB.Seaweed.lane6.NoInde...          68.426513   \n",
       "2300.BB.4087.anus                                           95.100000   \n",
       "2300.BB.4087.lavage20                                       95.100000   \n",
       "2300.BB.08.lavage20                                         97.200000   \n",
       "\n",
       "                                                    temperature_deg_f_2  \n",
       "#SampleID                                                                \n",
       "678.OA.mesocosm.362                                           51.800000  \n",
       "678.OA.mesocosm.376                                           51.440000  \n",
       "678.OA.mesocosm.410                                           53.780000  \n",
       "678.OA.mesocosm.417                                           51.800000  \n",
       "678.OA.mesocosm.431                                           51.980000  \n",
       "...                                                                 ...  \n",
       "2229.W2.T3.4.HP1.Thomas.CMB.Seaweed.lane5.NoInd...            64.940000  \n",
       "2229.W2.T33.PS5.Thomas.CMB.Seaweed.lane6.NoInde...            68.426513  \n",
       "2300.BB.4087.anus                                             95.100000  \n",
       "2300.BB.4087.lavage20                                         95.100000  \n",
       "2300.BB.08.lavage20                                           97.200000  \n",
       "\n",
       "[411 rows x 3 columns]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merged.loc[df_merged.temperature_deg_c.notna(), \n",
    "              ['temperature_deg_c', 'temperature_deg_f', 'temperature_deg_f_2']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Answer to E. Sorting"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "E1. Sort the rows in `df_merged` by `sequences_split_libraries` values from high to low and store the result as `df_merged`. (Hint: you can use `inplace=True`.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ph</th>\n",
       "      <th>temperature_deg_c</th>\n",
       "      <th>salinity_psu</th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "      <th>empo_3</th>\n",
       "      <th>temperature_deg_f</th>\n",
       "      <th>temperature_deg_f_2</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>#SampleID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1240.1512BCDNA</th>\n",
       "      <td>NaN</td>\n",
       "      <td>10.37</td>\n",
       "      <td>34.39</td>\n",
       "      <td>819180</td>\n",
       "      <td>657762</td>\n",
       "      <td>672649</td>\n",
       "      <td>814606</td>\n",
       "      <td>539745</td>\n",
       "      <td>545610</td>\n",
       "      <td>234531</td>\n",
       "      <td>Water (saline)</td>\n",
       "      <td>50.666</td>\n",
       "      <td>50.666</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1222.B5.5.14.06</th>\n",
       "      <td>NaN</td>\n",
       "      <td>9.30</td>\n",
       "      <td>31.50</td>\n",
       "      <td>747257</td>\n",
       "      <td>709386</td>\n",
       "      <td>713535</td>\n",
       "      <td>744797</td>\n",
       "      <td>555429</td>\n",
       "      <td>550169</td>\n",
       "      <td>294681</td>\n",
       "      <td>Water (saline)</td>\n",
       "      <td>48.740</td>\n",
       "      <td>48.740</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>810.1230C2H2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>737194</td>\n",
       "      <td>713117</td>\n",
       "      <td>717450</td>\n",
       "      <td>734793</td>\n",
       "      <td>460415</td>\n",
       "      <td>396263</td>\n",
       "      <td>0</td>\n",
       "      <td>Sediment (saline)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>638.FRX7.120910.2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>716093</td>\n",
       "      <td>593535</td>\n",
       "      <td>609665</td>\n",
       "      <td>705982</td>\n",
       "      <td>398992</td>\n",
       "      <td>358234</td>\n",
       "      <td>0</td>\n",
       "      <td>Water (non-saline)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242.ME04Jun01EB1R2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>699690</td>\n",
       "      <td>633858</td>\n",
       "      <td>635995</td>\n",
       "      <td>696427</td>\n",
       "      <td>433043</td>\n",
       "      <td>385579</td>\n",
       "      <td>0</td>\n",
       "      <td>Water (non-saline)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     ph  temperature_deg_c  salinity_psu  \\\n",
       "#SampleID                                                  \n",
       "1240.1512BCDNA      NaN              10.37         34.39   \n",
       "1222.B5.5.14.06     NaN               9.30         31.50   \n",
       "810.1230C2H2        NaN                NaN           NaN   \n",
       "638.FRX7.120910.2   NaN                NaN           NaN   \n",
       "1242.ME04Jun01EB1R2 NaN                NaN           NaN   \n",
       "\n",
       "                     sequences_split_libraries  \\\n",
       "#SampleID                                        \n",
       "1240.1512BCDNA                          819180   \n",
       "1222.B5.5.14.06                         747257   \n",
       "810.1230C2H2                            737194   \n",
       "638.FRX7.120910.2                       716093   \n",
       "1242.ME04Jun01EB1R2                     699690   \n",
       "\n",
       "                     observations_closed_ref_greengenes  \\\n",
       "#SampleID                                                 \n",
       "1240.1512BCDNA                                   657762   \n",
       "1222.B5.5.14.06                                  709386   \n",
       "810.1230C2H2                                     713117   \n",
       "638.FRX7.120910.2                                593535   \n",
       "1242.ME04Jun01EB1R2                              633858   \n",
       "\n",
       "                     observations_closed_ref_silva  \\\n",
       "#SampleID                                            \n",
       "1240.1512BCDNA                              672649   \n",
       "1222.B5.5.14.06                             713535   \n",
       "810.1230C2H2                                717450   \n",
       "638.FRX7.120910.2                           609665   \n",
       "1242.ME04Jun01EB1R2                         635995   \n",
       "\n",
       "                     observations_open_ref_greengenes  \\\n",
       "#SampleID                                               \n",
       "1240.1512BCDNA                                 814606   \n",
       "1222.B5.5.14.06                                744797   \n",
       "810.1230C2H2                                   734793   \n",
       "638.FRX7.120910.2                              705982   \n",
       "1242.ME04Jun01EB1R2                            696427   \n",
       "\n",
       "                     observations_deblur_90bp  observations_deblur_100bp  \\\n",
       "#SampleID                                                                  \n",
       "1240.1512BCDNA                         539745                     545610   \n",
       "1222.B5.5.14.06                        555429                     550169   \n",
       "810.1230C2H2                           460415                     396263   \n",
       "638.FRX7.120910.2                      398992                     358234   \n",
       "1242.ME04Jun01EB1R2                    433043                     385579   \n",
       "\n",
       "                     observations_deblur_150bp              empo_3  \\\n",
       "#SampleID                                                            \n",
       "1240.1512BCDNA                          234531      Water (saline)   \n",
       "1222.B5.5.14.06                         294681      Water (saline)   \n",
       "810.1230C2H2                                 0   Sediment (saline)   \n",
       "638.FRX7.120910.2                            0  Water (non-saline)   \n",
       "1242.ME04Jun01EB1R2                          0  Water (non-saline)   \n",
       "\n",
       "                     temperature_deg_f  temperature_deg_f_2  \n",
       "#SampleID                                                    \n",
       "1240.1512BCDNA                  50.666               50.666  \n",
       "1222.B5.5.14.06                 48.740               48.740  \n",
       "810.1230C2H2                       NaN                  NaN  \n",
       "638.FRX7.120910.2                  NaN                  NaN  \n",
       "1242.ME04Jun01EB1R2                NaN                  NaN  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merged.sort_values(by='sequences_split_libraries', ascending=False, inplace=True)\n",
    "df_merged.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "E2. Sort the columns in `df_merged` by column name from A to Z and store the result as `df_merged`. (Hint: you can use `inplace=True`.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>empo_3</th>\n",
       "      <th>observations_closed_ref_greengenes</th>\n",
       "      <th>observations_closed_ref_silva</th>\n",
       "      <th>observations_deblur_100bp</th>\n",
       "      <th>observations_deblur_150bp</th>\n",
       "      <th>observations_deblur_90bp</th>\n",
       "      <th>observations_open_ref_greengenes</th>\n",
       "      <th>ph</th>\n",
       "      <th>salinity_psu</th>\n",
       "      <th>sequences_split_libraries</th>\n",
       "      <th>temperature_deg_c</th>\n",
       "      <th>temperature_deg_f</th>\n",
       "      <th>temperature_deg_f_2</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>#SampleID</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1240.1512BCDNA</th>\n",
       "      <td>Water (saline)</td>\n",
       "      <td>657762</td>\n",
       "      <td>672649</td>\n",
       "      <td>545610</td>\n",
       "      <td>234531</td>\n",
       "      <td>539745</td>\n",
       "      <td>814606</td>\n",
       "      <td>NaN</td>\n",
       "      <td>34.39</td>\n",
       "      <td>819180</td>\n",
       "      <td>10.37</td>\n",
       "      <td>50.666</td>\n",
       "      <td>50.666</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1222.B5.5.14.06</th>\n",
       "      <td>Water (saline)</td>\n",
       "      <td>709386</td>\n",
       "      <td>713535</td>\n",
       "      <td>550169</td>\n",
       "      <td>294681</td>\n",
       "      <td>555429</td>\n",
       "      <td>744797</td>\n",
       "      <td>NaN</td>\n",
       "      <td>31.50</td>\n",
       "      <td>747257</td>\n",
       "      <td>9.30</td>\n",
       "      <td>48.740</td>\n",
       "      <td>48.740</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>810.1230C2H2</th>\n",
       "      <td>Sediment (saline)</td>\n",
       "      <td>713117</td>\n",
       "      <td>717450</td>\n",
       "      <td>396263</td>\n",
       "      <td>0</td>\n",
       "      <td>460415</td>\n",
       "      <td>734793</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>737194</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>638.FRX7.120910.2</th>\n",
       "      <td>Water (non-saline)</td>\n",
       "      <td>593535</td>\n",
       "      <td>609665</td>\n",
       "      <td>358234</td>\n",
       "      <td>0</td>\n",
       "      <td>398992</td>\n",
       "      <td>705982</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>716093</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242.ME04Jun01EB1R2</th>\n",
       "      <td>Water (non-saline)</td>\n",
       "      <td>633858</td>\n",
       "      <td>635995</td>\n",
       "      <td>385579</td>\n",
       "      <td>0</td>\n",
       "      <td>433043</td>\n",
       "      <td>696427</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>699690</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                 empo_3  observations_closed_ref_greengenes  \\\n",
       "#SampleID                                                                     \n",
       "1240.1512BCDNA           Water (saline)                              657762   \n",
       "1222.B5.5.14.06          Water (saline)                              709386   \n",
       "810.1230C2H2          Sediment (saline)                              713117   \n",
       "638.FRX7.120910.2    Water (non-saline)                              593535   \n",
       "1242.ME04Jun01EB1R2  Water (non-saline)                              633858   \n",
       "\n",
       "                     observations_closed_ref_silva  observations_deblur_100bp  \\\n",
       "#SampleID                                                                       \n",
       "1240.1512BCDNA                              672649                     545610   \n",
       "1222.B5.5.14.06                             713535                     550169   \n",
       "810.1230C2H2                                717450                     396263   \n",
       "638.FRX7.120910.2                           609665                     358234   \n",
       "1242.ME04Jun01EB1R2                         635995                     385579   \n",
       "\n",
       "                     observations_deblur_150bp  observations_deblur_90bp  \\\n",
       "#SampleID                                                                  \n",
       "1240.1512BCDNA                          234531                    539745   \n",
       "1222.B5.5.14.06                         294681                    555429   \n",
       "810.1230C2H2                                 0                    460415   \n",
       "638.FRX7.120910.2                            0                    398992   \n",
       "1242.ME04Jun01EB1R2                          0                    433043   \n",
       "\n",
       "                     observations_open_ref_greengenes  ph  salinity_psu  \\\n",
       "#SampleID                                                                 \n",
       "1240.1512BCDNA                                 814606 NaN         34.39   \n",
       "1222.B5.5.14.06                                744797 NaN         31.50   \n",
       "810.1230C2H2                                   734793 NaN           NaN   \n",
       "638.FRX7.120910.2                              705982 NaN           NaN   \n",
       "1242.ME04Jun01EB1R2                            696427 NaN           NaN   \n",
       "\n",
       "                     sequences_split_libraries  temperature_deg_c  \\\n",
       "#SampleID                                                           \n",
       "1240.1512BCDNA                          819180              10.37   \n",
       "1222.B5.5.14.06                         747257               9.30   \n",
       "810.1230C2H2                            737194                NaN   \n",
       "638.FRX7.120910.2                       716093                NaN   \n",
       "1242.ME04Jun01EB1R2                     699690                NaN   \n",
       "\n",
       "                     temperature_deg_f  temperature_deg_f_2  \n",
       "#SampleID                                                    \n",
       "1240.1512BCDNA                  50.666               50.666  \n",
       "1222.B5.5.14.06                 48.740               48.740  \n",
       "810.1230C2H2                       NaN                  NaN  \n",
       "638.FRX7.120910.2                  NaN                  NaN  \n",
       "1242.ME04Jun01EB1R2                NaN                  NaN  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merged.sort_index(axis=1, ascending=True, inplace=True)\n",
    "df_merged.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
